{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 504,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "import pandas\n",
    "df = pandas.read_csv('data/house_data.csv')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 检视前几行资料"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 506,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>参考月供</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>急售70年产权房源 房东装修 户型正气 产证清晰 随时看房</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1989年</td>\n",
       "      <td>70.40</td>\n",
       "      <td>2室2厅1厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>暂无资料</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>30.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>世纪大道站  福山外国语+建平西校 看房随时急卖</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>塔楼</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1989年</td>\n",
       "      <td>49.82</td>\n",
       "      <td>2室1厅0厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>1元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>简装修</td>\n",
       "      <td>418.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>大四房出售，带会所+高区景观+车位</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>288.30</td>\n",
       "      <td>4室2厅0厨2卫</td>\n",
       "      <td>高层(共40层)</td>\n",
       "      <td>3.5元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>2650.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0                             標題  产权性质  住宅类别 建筑类别  参考月供     年代  \\\n",
       "0           0  急售70年产权房源 房东装修 户型正气 产证清晰 随时看房  个人产权  普通住宅   板楼   NaN  1989年   \n",
       "1           1       世纪大道站  福山外国语+建平西校 看房随时急卖  个人产权  普通住宅   塔楼   NaN  1989年   \n",
       "2           2              大四房出售，带会所+高区景观+车位  个人产权  普通住宅  NaN   NaN  2005年   \n",
       "\n",
       "     建筑面积        户型        楼层      物 业 费 物业类型   结构   装修      總價  \n",
       "0   70.40  2室2厅1厨1卫   中层(共6层)       暂无资料   住宅   平层  精装修    30.6  \n",
       "1   49.82  2室1厅0厨1卫   中层(共6层)    1元/平米・月   住宅   平层  简装修   418.0  \n",
       "2  288.30  4室2厅0厨2卫  高层(共40层)  3.5元/平米・月   住宅  NaN  精装修  2650.0  "
      ]
     },
     "execution_count": 506,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 507,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>参考月供</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>急售70年产权房源 房东装修 户型正气 产证清晰 随时看房</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1989年</td>\n",
       "      <td>70.40</td>\n",
       "      <td>2室2厅1厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>暂无资料</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>30.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>世纪大道站  福山外国语+建平西校 看房随时急卖</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>塔楼</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1989年</td>\n",
       "      <td>49.82</td>\n",
       "      <td>2室1厅0厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>1元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>简装修</td>\n",
       "      <td>418.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>大四房出售，带会所+高区景观+车位</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>288.30</td>\n",
       "      <td>4室2厅0厨2卫</td>\n",
       "      <td>高层(共40层)</td>\n",
       "      <td>3.5元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>2650.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                              標題  产权性质  住宅类别 建筑类别  参考月供     年代    建筑面积  \\\n",
       "0  急售70年产权房源 房东装修 户型正气 产证清晰 随时看房  个人产权  普通住宅   板楼   NaN  1989年   70.40   \n",
       "1       世纪大道站  福山外国语+建平西校 看房随时急卖  个人产权  普通住宅   塔楼   NaN  1989年   49.82   \n",
       "2              大四房出售，带会所+高区景观+车位  个人产权  普通住宅  NaN   NaN  2005年  288.30   \n",
       "\n",
       "         户型        楼层      物 业 费 物业类型   结构   装修      總價  \n",
       "0  2室2厅1厨1卫   中层(共6层)       暂无资料   住宅   平层  精装修    30.6  \n",
       "1  2室1厅0厨1卫   中层(共6层)    1元/平米・月   住宅   平层  简装修   418.0  \n",
       "2  4室2厅0厨2卫  高层(共40层)  3.5元/平米・月   住宅  NaN  精装修  2650.0  "
      ]
     },
     "execution_count": 507,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "del df['Unnamed: 0']\n",
    "df.head(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 舍弃第一栏"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 508,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df = pandas.read_csv('data/house_data.csv',  index_col=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 509,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>参考月供</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>急售70年产权房源 房东装修 户型正气 产证清晰 随时看房</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1989年</td>\n",
       "      <td>70.40</td>\n",
       "      <td>2室2厅1厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>暂无资料</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>30.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>世纪大道站  福山外国语+建平西校 看房随时急卖</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>塔楼</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1989年</td>\n",
       "      <td>49.82</td>\n",
       "      <td>2室1厅0厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>1元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>简装修</td>\n",
       "      <td>418.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>大四房出售，带会所+高区景观+车位</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>288.30</td>\n",
       "      <td>4室2厅0厨2卫</td>\n",
       "      <td>高层(共40层)</td>\n",
       "      <td>3.5元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>2650.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                              標題  产权性质  住宅类别 建筑类别  参考月供     年代    建筑面积  \\\n",
       "0  急售70年产权房源 房东装修 户型正气 产证清晰 随时看房  个人产权  普通住宅   板楼   NaN  1989年   70.40   \n",
       "1       世纪大道站  福山外国语+建平西校 看房随时急卖  个人产权  普通住宅   塔楼   NaN  1989年   49.82   \n",
       "2              大四房出售，带会所+高区景观+车位  个人产权  普通住宅  NaN   NaN  2005年  288.30   \n",
       "\n",
       "         户型        楼层      物 业 费 物业类型   结构   装修      總價  \n",
       "0  2室2厅1厨1卫   中层(共6层)       暂无资料   住宅   平层  精装修    30.6  \n",
       "1  2室1厅0厨1卫   中层(共6层)    1元/平米・月   住宅   平层  简装修   418.0  \n",
       "2  4室2厅0厨2卫  高层(共40层)  3.5元/平米・月   住宅  NaN  精装修  2650.0  "
      ]
     },
     "execution_count": 509,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 将\"暂无资料\"变成缺失值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 513,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#df[df['物 业 费'] == '暂无资料']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 502,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>参考月供</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>急售70年产权房源 房东装修 户型正气 产证清晰 随时看房</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1989年</td>\n",
       "      <td>70.40</td>\n",
       "      <td>2室2厅1厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>30.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>世纪大道站  福山外国语+建平西校 看房随时急卖</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>塔楼</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1989年</td>\n",
       "      <td>49.82</td>\n",
       "      <td>2室1厅0厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>1元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>简装修</td>\n",
       "      <td>418.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>大四房出售，带会所+高区景观+车位</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>288.30</td>\n",
       "      <td>4室2厅0厨2卫</td>\n",
       "      <td>高层(共40层)</td>\n",
       "      <td>3.5元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>2650.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                              標題  产权性质  住宅类别 建筑类别  参考月供     年代    建筑面积  \\\n",
       "0  急售70年产权房源 房东装修 户型正气 产证清晰 随时看房  个人产权  普通住宅   板楼   NaN  1989年   70.40   \n",
       "1       世纪大道站  福山外国语+建平西校 看房随时急卖  个人产权  普通住宅   塔楼   NaN  1989年   49.82   \n",
       "2              大四房出售，带会所+高区景观+车位  个人产权  普通住宅  NaN   NaN  2005年  288.30   \n",
       "\n",
       "         户型        楼层      物 业 费 物业类型   结构   装修      總價  \n",
       "0  2室2厅1厨1卫   中层(共6层)        NaN   住宅   平层  精装修    30.6  \n",
       "1  2室1厅0厨1卫   中层(共6层)    1元/平米・月   住宅   平层  简装修   418.0  \n",
       "2  4室2厅0厨2卫  高层(共40层)  3.5元/平米・月   住宅  NaN  精装修  2650.0  "
      ]
     },
     "execution_count": 502,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "df.ix[df['物 业 费'] == '暂无资料', '物 业 费'] = np.nan\n",
    "df.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 515,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>参考月供</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>急售70年产权房源 房东装修 户型正气 产证清晰 随时看房</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1989年</td>\n",
       "      <td>70.40</td>\n",
       "      <td>2室2厅1厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>30.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>世纪大道站  福山外国语+建平西校 看房随时急卖</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>塔楼</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1989年</td>\n",
       "      <td>49.82</td>\n",
       "      <td>2室1厅0厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>1元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>简装修</td>\n",
       "      <td>418.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>大四房出售，带会所+高区景观+车位</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>288.30</td>\n",
       "      <td>4室2厅0厨2卫</td>\n",
       "      <td>高层(共40层)</td>\n",
       "      <td>3.5元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>2650.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                              標題  产权性质  住宅类别 建筑类别  参考月供     年代    建筑面积  \\\n",
       "0  急售70年产权房源 房东装修 户型正气 产证清晰 随时看房  个人产权  普通住宅   板楼   NaN  1989年   70.40   \n",
       "1       世纪大道站  福山外国语+建平西校 看房随时急卖  个人产权  普通住宅   塔楼   NaN  1989年   49.82   \n",
       "2              大四房出售，带会所+高区景观+车位  个人产权  普通住宅  NaN   NaN  2005年  288.30   \n",
       "\n",
       "         户型        楼层      物 业 费 物业类型   结构   装修      總價  \n",
       "0  2室2厅1厨1卫   中层(共6层)        NaN   住宅   平层  精装修    30.6  \n",
       "1  2室1厅0厨1卫   中层(共6层)    1元/平米・月   住宅   平层  简装修   418.0  \n",
       "2  4室2厅0厨2卫  高层(共40层)  3.5元/平米・月   住宅  NaN  精装修  2650.0  "
      ]
     },
     "execution_count": 515,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas\n",
    "df = pandas.read_csv('data/house_data.csv', na_values='暂无资料',  index_col=0)\n",
    "df.head(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 检视后三行资料"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 514,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>参考月供</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>237</th>\n",
       "      <td>6.12双轨，交通便利，配套成熟，购物方便，房东可接受置换！</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>钢混</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>96.82</td>\n",
       "      <td>2室2厅1厨1卫</td>\n",
       "      <td>高层(共8层)</td>\n",
       "      <td>1.86元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>460.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>238</th>\n",
       "      <td>业主二次装修，保养好，户型方正，三房朝南，，随时看</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2002年</td>\n",
       "      <td>168.00</td>\n",
       "      <td>3室2厅1厨2卫</td>\n",
       "      <td>高层(共20层)</td>\n",
       "      <td>2元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>简装修</td>\n",
       "      <td>1250.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>239</th>\n",
       "      <td>区进门位置 三街坊43平直套通风一房 一梯二户 房东诚心卖</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1996年</td>\n",
       "      <td>43.13</td>\n",
       "      <td>1室1厅1厨1卫</td>\n",
       "      <td>高层(共7层)</td>\n",
       "      <td>0.3元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>简装修</td>\n",
       "      <td>278.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                 標題  产权性质  住宅类别 建筑类别  参考月供     年代    建筑面积  \\\n",
       "237  6.12双轨，交通便利，配套成熟，购物方便，房东可接受置换！  个人产权  普通住宅   钢混   NaN  2005年   96.82   \n",
       "238       业主二次装修，保养好，户型方正，三房朝南，，随时看  个人产权  普通住宅   板楼   NaN  2002年  168.00   \n",
       "239   区进门位置 三街坊43平直套通风一房 一梯二户 房东诚心卖  个人产权  普通住宅   板楼   NaN  1996年   43.13   \n",
       "\n",
       "           户型        楼层       物 业 费 物业类型  结构   装修      總價  \n",
       "237  2室2厅1厨1卫   高层(共8层)  1.86元/平米・月   住宅  平层  精装修   460.0  \n",
       "238  3室2厅1厨2卫  高层(共20层)     2元/平米・月   住宅  平层  简装修  1250.0  \n",
       "239  1室1厅1厨1卫   高层(共7层)   0.3元/平米・月   住宅  平层  简装修   278.0  "
      ]
     },
     "execution_count": 514,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.tail(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 检视DataFrame 信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 516,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 240 entries, 0 to 239\n",
      "Data columns (total 14 columns):\n",
      "標題       240 non-null object\n",
      "产权性质     228 non-null object\n",
      "住宅类别     218 non-null object\n",
      "建筑类别     188 non-null object\n",
      "参考月供     0 non-null float64\n",
      "年代       224 non-null object\n",
      "建筑面积     240 non-null float64\n",
      "户型       240 non-null object\n",
      "楼层       228 non-null object\n",
      "物 业 费    215 non-null object\n",
      "物业类型     240 non-null object\n",
      "结构       181 non-null object\n",
      "装修       228 non-null object\n",
      "總價       237 non-null float64\n",
      "dtypes: float64(3), object(11)\n",
      "memory usage: 28.1+ KB\n"
     ]
    }
   ],
   "source": [
    "df.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 检视字段名称"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 517,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['標題', '产权性质', '住宅类别', '建筑类别', '参考月供', '年代', '建筑面积', '户型', '楼层', '物 业 费',\n",
       "       '物业类型', '结构', '装修', '總價'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 517,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 检视字段型态"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 518,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "標題        object\n",
       "产权性质      object\n",
       "住宅类别      object\n",
       "建筑类别      object\n",
       "参考月供     float64\n",
       "年代        object\n",
       "建筑面积     float64\n",
       "户型        object\n",
       "楼层        object\n",
       "物 业 费     object\n",
       "物业类型      object\n",
       "结构        object\n",
       "装修        object\n",
       "總價       float64\n",
       "dtype: object"
      ]
     },
     "execution_count": 518,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.dtypes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 取得叙述性统计"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 519,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>参考月供</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>0.0</td>\n",
       "      <td>240.000000</td>\n",
       "      <td>237.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>NaN</td>\n",
       "      <td>113.435333</td>\n",
       "      <td>646.092869</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>NaN</td>\n",
       "      <td>99.199836</td>\n",
       "      <td>1300.349319</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>NaN</td>\n",
       "      <td>22.500000</td>\n",
       "      <td>30.600000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>NaN</td>\n",
       "      <td>68.952500</td>\n",
       "      <td>220.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>NaN</td>\n",
       "      <td>88.155000</td>\n",
       "      <td>400.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>NaN</td>\n",
       "      <td>123.250000</td>\n",
       "      <td>578.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>NaN</td>\n",
       "      <td>731.240000</td>\n",
       "      <td>11000.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       参考月供        建筑面积            總價\n",
       "count   0.0  240.000000    237.000000\n",
       "mean    NaN  113.435333    646.092869\n",
       "std     NaN   99.199836   1300.349319\n",
       "min     NaN   22.500000     30.600000\n",
       "25%     NaN   68.952500    220.000000\n",
       "50%     NaN   88.155000    400.000000\n",
       "75%     NaN  123.250000    578.000000\n",
       "max     NaN  731.240000  11000.000000"
      ]
     },
     "execution_count": 519,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 侦测缺失值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 521,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#df.isnull()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 522,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "標題       False\n",
       "产权性质      True\n",
       "住宅类别      True\n",
       "建筑类别      True\n",
       "参考月供      True\n",
       "年代        True\n",
       "建筑面积     False\n",
       "户型       False\n",
       "楼层        True\n",
       "物 业 费     True\n",
       "物业类型     False\n",
       "结构        True\n",
       "装修        True\n",
       "總價        True\n",
       "dtype: bool"
      ]
     },
     "execution_count": 522,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.isnull().any()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 523,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "標題         0\n",
       "产权性质      12\n",
       "住宅类别      22\n",
       "建筑类别      52\n",
       "参考月供     240\n",
       "年代        16\n",
       "建筑面积       0\n",
       "户型         0\n",
       "楼层        12\n",
       "物 业 费     25\n",
       "物业类型       0\n",
       "结构        59\n",
       "装修        12\n",
       "總價         3\n",
       "dtype: int64"
      ]
     },
     "execution_count": 523,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 474,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "標題       0.000000\n",
       "产权性质     0.052632\n",
       "住宅类别     0.100917\n",
       "建筑类别     0.276596\n",
       "参考月供          inf\n",
       "年代       0.071429\n",
       "建筑面积     0.000000\n",
       "户型       0.000000\n",
       "楼层       0.052632\n",
       "物 业 费    0.116279\n",
       "物业类型     0.000000\n",
       "结构       0.325967\n",
       "装修       0.052632\n",
       "總價       0.012658\n",
       "dtype: float64"
      ]
     },
     "execution_count": 474,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.isnull().sum() / df.count()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 删除有缺失值的字段"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 524,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>参考月供</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>急售70年产权房源 房东装修 户型正气 产证清晰 随时看房</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1989年</td>\n",
       "      <td>70.40</td>\n",
       "      <td>2室2厅1厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>30.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>世纪大道站  福山外国语+建平西校 看房随时急卖</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>塔楼</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1989年</td>\n",
       "      <td>49.82</td>\n",
       "      <td>2室1厅0厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>1元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>简装修</td>\n",
       "      <td>418.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>大四房出售，带会所+高区景观+车位</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>288.30</td>\n",
       "      <td>4室2厅0厨2卫</td>\n",
       "      <td>高层(共40层)</td>\n",
       "      <td>3.5元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>2650.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                              標題  产权性质  住宅类别 建筑类别  参考月供     年代    建筑面积  \\\n",
       "0  急售70年产权房源 房东装修 户型正气 产证清晰 随时看房  个人产权  普通住宅   板楼   NaN  1989年   70.40   \n",
       "1       世纪大道站  福山外国语+建平西校 看房随时急卖  个人产权  普通住宅   塔楼   NaN  1989年   49.82   \n",
       "2              大四房出售，带会所+高区景观+车位  个人产权  普通住宅  NaN   NaN  2005年  288.30   \n",
       "\n",
       "         户型        楼层      物 业 费 物业类型   结构   装修      總價  \n",
       "0  2室2厅1厨1卫   中层(共6层)        NaN   住宅   平层  精装修    30.6  \n",
       "1  2室1厅0厨1卫   中层(共6层)    1元/平米・月   住宅   平层  简装修   418.0  \n",
       "2  4室2厅0厨2卫  高层(共40层)  3.5元/平米・月   住宅  NaN  精装修  2650.0  "
      ]
     },
     "execution_count": 524,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 525,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "df = df.drop('参考月供', axis = 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 526,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>急售70年产权房源 房东装修 户型正气 产证清晰 随时看房</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>1989年</td>\n",
       "      <td>70.40</td>\n",
       "      <td>2室2厅1厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>30.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>世纪大道站  福山外国语+建平西校 看房随时急卖</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>塔楼</td>\n",
       "      <td>1989年</td>\n",
       "      <td>49.82</td>\n",
       "      <td>2室1厅0厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>1元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>简装修</td>\n",
       "      <td>418.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>大四房出售，带会所+高区景观+车位</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>288.30</td>\n",
       "      <td>4室2厅0厨2卫</td>\n",
       "      <td>高层(共40层)</td>\n",
       "      <td>3.5元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>2650.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                              標題  产权性质  住宅类别 建筑类别     年代    建筑面积        户型  \\\n",
       "0  急售70年产权房源 房东装修 户型正气 产证清晰 随时看房  个人产权  普通住宅   板楼  1989年   70.40  2室2厅1厨1卫   \n",
       "1       世纪大道站  福山外国语+建平西校 看房随时急卖  个人产权  普通住宅   塔楼  1989年   49.82  2室1厅0厨1卫   \n",
       "2              大四房出售，带会所+高区景观+车位  个人产权  普通住宅  NaN  2005年  288.30  4室2厅0厨2卫   \n",
       "\n",
       "         楼层      物 业 费 物业类型   结构   装修      總價  \n",
       "0   中层(共6层)        NaN   住宅   平层  精装修    30.6  \n",
       "1   中层(共6层)    1元/平米・月   住宅   平层  简装修   418.0  \n",
       "2  高层(共40层)  3.5元/平米・月   住宅  NaN  精装修  2650.0  "
      ]
     },
     "execution_count": 526,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 筛选字段"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 477,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "个人产权     171\n",
       "商品房       54\n",
       "经济适用房      2\n",
       "售后公房       1\n",
       "Name: 产权性质, dtype: int64"
      ]
     },
     "execution_count": 477,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['产权性质'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 530,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#df[df['产权性质'] == '个人产权']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 478,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>急售70年产权房源 房东装修 户型正气 产证清晰 随时看房</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>1989年</td>\n",
       "      <td>70.40</td>\n",
       "      <td>2室2厅1厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>30.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>世纪大道站  福山外国语+建平西校 看房随时急卖</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>塔楼</td>\n",
       "      <td>1989年</td>\n",
       "      <td>49.82</td>\n",
       "      <td>2室1厅0厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>1元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>简装修</td>\n",
       "      <td>418.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>大四房出售，带会所+高区景观+车位</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>288.30</td>\n",
       "      <td>4室2厅0厨2卫</td>\n",
       "      <td>高层(共40层)</td>\n",
       "      <td>3.5元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>2650.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                              標題  产权性质  住宅类别 建筑类别     年代    建筑面积        户型  \\\n",
       "0  急售70年产权房源 房东装修 户型正气 产证清晰 随时看房  个人产权  普通住宅   板楼  1989年   70.40  2室2厅1厨1卫   \n",
       "1       世纪大道站  福山外国语+建平西校 看房随时急卖  个人产权  普通住宅   塔楼  1989年   49.82  2室1厅0厨1卫   \n",
       "2              大四房出售，带会所+高区景观+车位  个人产权  普通住宅  NaN  2005年  288.30  4室2厅0厨2卫   \n",
       "\n",
       "         楼层      物 业 费 物业类型   结构   装修      總價  \n",
       "0   中层(共6层)        NaN   住宅   平层  精装修    30.6  \n",
       "1   中层(共6层)    1元/平米・月   住宅   平层  简装修   418.0  \n",
       "2  高层(共40层)  3.5元/平米・月   住宅  NaN  精装修  2650.0  "
      ]
     },
     "execution_count": 478,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df['产权性质'] == '个人产权'].head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 531,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>延吉控江一楼天井精装修水丰南北通透</td>\n",
       "      <td>商品房</td>\n",
       "      <td>NaN</td>\n",
       "      <td>板楼</td>\n",
       "      <td>1986年</td>\n",
       "      <td>35.0</td>\n",
       "      <td>1室2厅1厨1卫</td>\n",
       "      <td>低层(共6层)</td>\n",
       "      <td>0.85元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>简装修</td>\n",
       "      <td>205.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>纯双拼别墅，外环旁低总价，奢华大厅，美极了</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>237.0</td>\n",
       "      <td>4室3厅1厨4卫</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.8元/平米・月</td>\n",
       "      <td>别墅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1000.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                      標題 产权性质 住宅类别 建筑类别     年代   建筑面积        户型       楼层  \\\n",
       "5      延吉控江一楼天井精装修水丰南北通透  商品房  NaN   板楼  1986年   35.0  1室2厅1厨1卫  低层(共6层)   \n",
       "6  纯双拼别墅，外环旁低总价，奢华大厅，美极了  NaN  NaN  NaN    NaN  237.0  4室3厅1厨4卫      NaN   \n",
       "\n",
       "        物 业 费 物业类型   结构   装修      總價  \n",
       "5  0.85元/平米・月   住宅   平层  简装修   205.0  \n",
       "6   3.8元/平米・月   别墅  NaN  NaN  1000.0  "
      ]
     },
     "execution_count": 531,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[5:7]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 480,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>大四房出售，带会所+高区景观+车位</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>288.3</td>\n",
       "      <td>4室2厅0厨2卫</td>\n",
       "      <td>高层(共40层)</td>\n",
       "      <td>3.5元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>2650.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  標題  产权性质  住宅类别 建筑类别     年代   建筑面积        户型        楼层  \\\n",
       "2  大四房出售，带会所+高区景观+车位  个人产权  普通住宅  NaN  2005年  288.3  4室2厅0厨2卫  高层(共40层)   \n",
       "\n",
       "       物 业 费 物业类型   结构   装修      總價  \n",
       "2  3.5元/平米・月   住宅  NaN  精装修  2650.0  "
      ]
     },
     "execution_count": 480,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.ix[(df['建筑面积'] > 100) & (df['總價'] > 2000) , ].head(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 481,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>大四房出售，带会所+高区景观+车位</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>288.3</td>\n",
       "      <td>4室2厅0厨2卫</td>\n",
       "      <td>高层(共40层)</td>\n",
       "      <td>3.5元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>2650.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  標題  产权性质  住宅类别 建筑类别     年代   建筑面积        户型        楼层  \\\n",
       "2  大四房出售，带会所+高区景观+车位  个人产权  普通住宅  NaN  2005年  288.3  4室2厅0厨2卫  高层(共40层)   \n",
       "\n",
       "       物 业 费 物业类型   结构   装修      總價  \n",
       "2  3.5元/平米・月   住宅  NaN  精装修  2650.0  "
      ]
     },
     "execution_count": 481,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[df['建筑面积'] > 100].head(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 533,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>急售70年产权房源 房东装修 户型正气 产证清晰 随时看房</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>1989年</td>\n",
       "      <td>70.40</td>\n",
       "      <td>2室2厅1厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>30.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>世纪大道站  福山外国语+建平西校 看房随时急卖</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>塔楼</td>\n",
       "      <td>1989年</td>\n",
       "      <td>49.82</td>\n",
       "      <td>2室1厅0厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>1元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>简装修</td>\n",
       "      <td>418.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>大四房出售，带会所+高区景观+车位</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>288.30</td>\n",
       "      <td>4室2厅0厨2卫</td>\n",
       "      <td>高层(共40层)</td>\n",
       "      <td>3.5元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>2650.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                              標題  产权性质  住宅类别 建筑类别     年代    建筑面积        户型  \\\n",
       "0  急售70年产权房源 房东装修 户型正气 产证清晰 随时看房  个人产权  普通住宅   板楼  1989年   70.40  2室2厅1厨1卫   \n",
       "1       世纪大道站  福山外国语+建平西校 看房随时急卖  个人产权  普通住宅   塔楼  1989年   49.82  2室1厅0厨1卫   \n",
       "2              大四房出售，带会所+高区景观+车位  个人产权  普通住宅  NaN  2005年  288.30  4室2厅0厨2卫   \n",
       "\n",
       "         楼层      物 业 费 物业类型   结构   装修      總價  \n",
       "0   中层(共6层)        NaN   住宅   平层  精装修    30.6  \n",
       "1   中层(共6层)    1元/平米・月   住宅   平层  简装修   418.0  \n",
       "2  高层(共40层)  3.5元/平米・月   住宅  NaN  精装修  2650.0  "
      ]
     },
     "execution_count": 533,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = df[df['产权性质'] == '个人产权']\n",
    "df.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 534,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "个人产权    171\n",
       "Name: 产权性质, dtype: int64"
      ]
     },
     "execution_count": 534,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['产权性质'].value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 舍弃包含缺失值的字段"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 535,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>急售70年产权房源 房东装修 户型正气 产证清晰 随时看房</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>1989年</td>\n",
       "      <td>70.40</td>\n",
       "      <td>2室2厅1厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>30.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>世纪大道站  福山外国语+建平西校 看房随时急卖</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>塔楼</td>\n",
       "      <td>1989年</td>\n",
       "      <td>49.82</td>\n",
       "      <td>2室1厅0厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>1元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>简装修</td>\n",
       "      <td>418.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>大四房出售，带会所+高区景观+车位</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>288.30</td>\n",
       "      <td>4室2厅0厨2卫</td>\n",
       "      <td>高层(共40层)</td>\n",
       "      <td>3.5元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>2650.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                              標題  产权性质  住宅类别 建筑类别     年代    建筑面积        户型  \\\n",
       "0  急售70年产权房源 房东装修 户型正气 产证清晰 随时看房  个人产权  普通住宅   板楼  1989年   70.40  2室2厅1厨1卫   \n",
       "1       世纪大道站  福山外国语+建平西校 看房随时急卖  个人产权  普通住宅   塔楼  1989年   49.82  2室1厅0厨1卫   \n",
       "2              大四房出售，带会所+高区景观+车位  个人产权  普通住宅  NaN  2005年  288.30  4室2厅0厨2卫   \n",
       "\n",
       "         楼层      物 业 费 物业类型   结构   装修      總價  \n",
       "0   中层(共6层)        NaN   住宅   平层  精装修    30.6  \n",
       "1   中层(共6层)    1元/平米・月   住宅   平层  简装修   418.0  \n",
       "2  高层(共40层)  3.5元/平米・月   住宅  NaN  精装修  2650.0  "
      ]
     },
     "execution_count": 535,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 483,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>大四房出售，带会所+高区景观+车位</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>288.30</td>\n",
       "      <td>4室2厅0厨2卫</td>\n",
       "      <td>高层(共40层)</td>\n",
       "      <td>3.5元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>2650.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>月浦八村繁华地段 毗邻公园双南两房 双轨交通</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1991年</td>\n",
       "      <td>47.12</td>\n",
       "      <td>2室0厅0厨1卫</td>\n",
       "      <td>高层(共6层)</td>\n",
       "      <td>0.6元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>中装修</td>\n",
       "      <td>180.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>投咨300亿山水六旗主题公园 金色海岸 海景房 得房率110</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2016年</td>\n",
       "      <td>84.00</td>\n",
       "      <td>2室2厅0厨1卫</td>\n",
       "      <td>中层(共15层)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>毛坯</td>\n",
       "      <td>80.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                標題  产权性质  住宅类别 建筑类别     年代    建筑面积        户型  \\\n",
       "2                大四房出售，带会所+高区景观+车位  个人产权  普通住宅  NaN  2005年  288.30  4室2厅0厨2卫   \n",
       "12          月浦八村繁华地段 毗邻公园双南两房 双轨交通  个人产权  普通住宅  NaN  1991年   47.12  2室0厅0厨1卫   \n",
       "27  投咨300亿山水六旗主题公园 金色海岸 海景房 得房率110  个人产权  普通住宅  NaN  2016年   84.00  2室2厅0厨1卫   \n",
       "\n",
       "          楼层      物 业 费 物业类型   结构   装修      總價  \n",
       "2   高层(共40层)  3.5元/平米・月   住宅  NaN  精装修  2650.0  \n",
       "12   高层(共6层)  0.6元/平米・月   住宅  NaN  中装修   180.0  \n",
       "27  中层(共15层)        NaN   住宅  NaN   毛坯    80.0  "
      ]
     },
     "execution_count": 483,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df['建筑类别'].isnull()].head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 536,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "df = df.dropna(axis=1, how='all')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 537,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>急售70年产权房源 房东装修 户型正气 产证清晰 随时看房</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>1989年</td>\n",
       "      <td>70.40</td>\n",
       "      <td>2室2厅1厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>30.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>世纪大道站  福山外国语+建平西校 看房随时急卖</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>塔楼</td>\n",
       "      <td>1989年</td>\n",
       "      <td>49.82</td>\n",
       "      <td>2室1厅0厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>1元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>简装修</td>\n",
       "      <td>418.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>大四房出售，带会所+高区景观+车位</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>288.30</td>\n",
       "      <td>4室2厅0厨2卫</td>\n",
       "      <td>高层(共40层)</td>\n",
       "      <td>3.5元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>2650.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                              標題  产权性质  住宅类别 建筑类别     年代    建筑面积        户型  \\\n",
       "0  急售70年产权房源 房东装修 户型正气 产证清晰 随时看房  个人产权  普通住宅   板楼  1989年   70.40  2室2厅1厨1卫   \n",
       "1       世纪大道站  福山外国语+建平西校 看房随时急卖  个人产权  普通住宅   塔楼  1989年   49.82  2室1厅0厨1卫   \n",
       "2              大四房出售，带会所+高区景观+车位  个人产权  普通住宅  NaN  2005年  288.30  4室2厅0厨2卫   \n",
       "\n",
       "         楼层      物 业 费 物业类型   结构   装修      總價  \n",
       "0   中层(共6层)        NaN   住宅   平层  精装修    30.6  \n",
       "1   中层(共6层)    1元/平米・月   住宅   平层  简装修   418.0  \n",
       "2  高层(共40层)  3.5元/平米・月   住宅  NaN  精装修  2650.0  "
      ]
     },
     "execution_count": 537,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 补齐缺失值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 538,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>急售70年产权房源 房东装修 户型正气 产证清晰 随时看房</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>1989年</td>\n",
       "      <td>70.40</td>\n",
       "      <td>2室2厅1厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>30.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>世纪大道站  福山外国语+建平西校 看房随时急卖</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>塔楼</td>\n",
       "      <td>1989年</td>\n",
       "      <td>49.82</td>\n",
       "      <td>2室1厅0厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>1元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>简装修</td>\n",
       "      <td>418.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>大四房出售，带会所+高区景观+车位</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>288.30</td>\n",
       "      <td>4室2厅0厨2卫</td>\n",
       "      <td>高层(共40层)</td>\n",
       "      <td>3.5元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>2650.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                              標題  产权性质  住宅类别 建筑类别     年代    建筑面积        户型  \\\n",
       "0  急售70年产权房源 房东装修 户型正气 产证清晰 随时看房  个人产权  普通住宅   板楼  1989年   70.40  2室2厅1厨1卫   \n",
       "1       世纪大道站  福山外国语+建平西校 看房随时急卖  个人产权  普通住宅   塔楼  1989年   49.82  2室1厅0厨1卫   \n",
       "2              大四房出售，带会所+高区景观+车位  个人产权  普通住宅  NaN  2005年  288.30  4室2厅0厨2卫   \n",
       "\n",
       "         楼层      物 业 费 物业类型   结构   装修      總價  \n",
       "0   中层(共6层)        NaN   住宅   平层  精装修    30.6  \n",
       "1   中层(共6层)    1元/平米・月   住宅   平层  简装修   418.0  \n",
       "2  高层(共40层)  3.5元/平米・月   住宅  NaN  精装修  2650.0  "
      ]
     },
     "execution_count": 538,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 539,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "df['物 业 费'] =df['物 业 费'].fillna(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 540,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>急售70年产权房源 房东装修 户型正气 产证清晰 随时看房</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>1989年</td>\n",
       "      <td>70.40</td>\n",
       "      <td>2室2厅1厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>0</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>30.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>世纪大道站  福山外国语+建平西校 看房随时急卖</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>塔楼</td>\n",
       "      <td>1989年</td>\n",
       "      <td>49.82</td>\n",
       "      <td>2室1厅0厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>1元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>简装修</td>\n",
       "      <td>418.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>大四房出售，带会所+高区景观+车位</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>288.30</td>\n",
       "      <td>4室2厅0厨2卫</td>\n",
       "      <td>高层(共40层)</td>\n",
       "      <td>3.5元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>2650.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                              標題  产权性质  住宅类别 建筑类别     年代    建筑面积        户型  \\\n",
       "0  急售70年产权房源 房东装修 户型正气 产证清晰 随时看房  个人产权  普通住宅   板楼  1989年   70.40  2室2厅1厨1卫   \n",
       "1       世纪大道站  福山外国语+建平西校 看房随时急卖  个人产权  普通住宅   塔楼  1989年   49.82  2室1厅0厨1卫   \n",
       "2              大四房出售，带会所+高区景观+车位  个人产权  普通住宅  NaN  2005年  288.30  4室2厅0厨2卫   \n",
       "\n",
       "         楼层      物 业 费 物业类型   结构   装修      總價  \n",
       "0   中层(共6层)          0   住宅   平层  精装修    30.6  \n",
       "1   中层(共6层)    1元/平米・月   住宅   平层  简装修   418.0  \n",
       "2  高层(共40层)  3.5元/平米・月   住宅  NaN  精装修  2650.0  "
      ]
     },
     "execution_count": 540,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 543,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 543,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['總價'].isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 544,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>光新路191弄 南北通透两室户 地段佳 出行方便满五少税</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>1990年</td>\n",
       "      <td>47.00</td>\n",
       "      <td>2室1厅1厨1卫</td>\n",
       "      <td>低层(共6层)</td>\n",
       "      <td>0.3元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>175</th>\n",
       "      <td>精品好房 稍纵即逝</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>钢混</td>\n",
       "      <td>2014年</td>\n",
       "      <td>99.38</td>\n",
       "      <td>3室2厅1厨2卫</td>\n",
       "      <td>中层(共11层)</td>\n",
       "      <td>1.95元/・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                               標題  产权性质  住宅类别 建筑类别     年代   建筑面积        户型  \\\n",
       "18   光新路191弄 南北通透两室户 地段佳 出行方便满五少税  个人产权  普通住宅   板楼  1990年  47.00  2室1厅1厨1卫   \n",
       "175                     精品好房 稍纵即逝  个人产权  普通住宅   钢混  2014年  99.38  3室2厅1厨2卫   \n",
       "\n",
       "           楼层      物 业 费 物业类型  结构   装修  總價  \n",
       "18    低层(共6层)  0.3元/平米・月   住宅  平层  精装修 NaN  \n",
       "175  中层(共11层)   1.95元/・月   住宅  平层  精装修 NaN  "
      ]
     },
     "execution_count": 544,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df['總價'].isnull()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 545,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4.5302593877717445"
      ]
     },
     "execution_count": 545,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(df['總價'] / df['建筑面积']).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 489,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 489,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['總價'].isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 546,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "df['總價'] = df['總價'].fillna(df['建筑面积'] * (df['總價'] / df['建筑面积']).mean())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 547,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 547,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['總價'].isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 548,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>標題</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>建筑类别</th>\n",
       "      <th>年代</th>\n",
       "      <th>建筑面积</th>\n",
       "      <th>户型</th>\n",
       "      <th>楼层</th>\n",
       "      <th>物 业 费</th>\n",
       "      <th>物业类型</th>\n",
       "      <th>结构</th>\n",
       "      <th>装修</th>\n",
       "      <th>總價</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>急售70年产权房源 房东装修 户型正气 产证清晰 随时看房</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>1989年</td>\n",
       "      <td>70.40</td>\n",
       "      <td>2室2厅1厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>0</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>30.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>世纪大道站  福山外国语+建平西校 看房随时急卖</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>塔楼</td>\n",
       "      <td>1989年</td>\n",
       "      <td>49.82</td>\n",
       "      <td>2室1厅0厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>1元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>简装修</td>\n",
       "      <td>418.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>大四房出售，带会所+高区景观+车位</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2005年</td>\n",
       "      <td>288.30</td>\n",
       "      <td>4室2厅0厨2卫</td>\n",
       "      <td>高层(共40层)</td>\n",
       "      <td>3.5元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>2650.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>满五税费少,房东接受置换客户,房东这边房子已经看好,急卖</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>钢混</td>\n",
       "      <td>1998年</td>\n",
       "      <td>58.00</td>\n",
       "      <td>2室1厅1厨1卫</td>\n",
       "      <td>高层(共6层)</td>\n",
       "      <td>0.4元/平米・月</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>190.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>纪联小区，，大一房一厅，精装修，，！诚售</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>板楼</td>\n",
       "      <td>1996年</td>\n",
       "      <td>50.00</td>\n",
       "      <td>1室1厅1厨1卫</td>\n",
       "      <td>中层(共6层)</td>\n",
       "      <td>0</td>\n",
       "      <td>住宅</td>\n",
       "      <td>平层</td>\n",
       "      <td>精装修</td>\n",
       "      <td>230.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                              標題  产权性质  住宅类别 建筑类别     年代    建筑面积        户型  \\\n",
       "0  急售70年产权房源 房东装修 户型正气 产证清晰 随时看房  个人产权  普通住宅   板楼  1989年   70.40  2室2厅1厨1卫   \n",
       "1       世纪大道站  福山外国语+建平西校 看房随时急卖  个人产权  普通住宅   塔楼  1989年   49.82  2室1厅0厨1卫   \n",
       "2              大四房出售，带会所+高区景观+车位  个人产权  普通住宅  NaN  2005年  288.30  4室2厅0厨2卫   \n",
       "4   满五税费少,房东接受置换客户,房东这边房子已经看好,急卖  个人产权  普通住宅   钢混  1998年   58.00  2室1厅1厨1卫   \n",
       "7           纪联小区，，大一房一厅，精装修，，！诚售  个人产权  普通住宅   板楼  1996年   50.00  1室1厅1厨1卫   \n",
       "\n",
       "         楼层      物 业 费 物业类型   结构   装修      總價  \n",
       "0   中层(共6层)          0   住宅   平层  精装修    30.6  \n",
       "1   中层(共6层)    1元/平米・月   住宅   平层  简装修   418.0  \n",
       "2  高层(共40层)  3.5元/平米・月   住宅  NaN  精装修  2650.0  \n",
       "4   高层(共6层)  0.4元/平米・月   住宅   平层  精装修   190.0  \n",
       "7   中层(共6层)          0   住宅   平层  精装修   230.0  "
      ]
     },
     "execution_count": 548,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 将资料写入CSV 中"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 549,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "df.to_csv('house_final.csv', index_label=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
